package servlets;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import util.StringConstants;

import database.DatabaseOperations;

public class EditJob extends HttpServlet {


	public void doPost(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {

		DatabaseOperations databaseOperations = new DatabaseOperations();
		try {
			
			int orderId = Integer.parseInt(req.getParameter("orderId_edit"));
			String newExpName = req.getParameter("expName_edit");
			String newDestName = req.getParameter("destName_edit");
			String newExpAddress = req.getParameter("expAddress_edit");
			String newDestAddress = req.getParameter("destAddress_edit");
			String newTransporterName = req.getParameter("transporterName_edit");
			String jobState = req.getParameter("jobState_edit");
			System.out.println(jobState);
			
			databaseOperations.editJob(orderId, newExpName, newExpAddress, newDestName, newDestAddress, newTransporterName, jobState);
		} finally {
			
			databaseOperations.closeConnection();
		}
		res.sendRedirect(StringConstants.admin_homepage);
	}
	
}
